home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / modes / linuxdoc-sgml.el.z / linuxdoc-sgml.el
Encoding:
Text File  |  1998-05-21  |  5.9 KB  |  177 lines

  1. ;;; linuxdoc-sgml.el --- sgml-mode enhancements for linuxdoc
  2.  
  3. ;; Copyright (C) 1996 by Free Software Foundation, Inc.
  4.  
  5. ;; Author: Arun Sharma <asharma@sco.com>
  6. ;; Keywords: docs, languages
  7.  
  8. ;; This file is part of GNU Emacs.
  9.  
  10. ;; GNU Emacs is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  22. ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. ;; Boston, MA 02111-1307, USA.
  24.  
  25. ;;; Commentary:
  26.  
  27. ;; Installation:
  28. ;;     Make sure that this file is in your load-path and put this line
  29. ;;     in your .emacs.
  30. ;;     (autoload 'linuxdoc-sgml-mode "linuxdoc-sgml" t t)
  31. ;;     (setq auto-mode-alist (cons '("\\.sgml$" . linuxdoc-sgml-mode)
  32. ;;                                  auto-mode-alist))
  33. ;; 
  34. ;; Optionally:
  35. ;;     (add-hook 'linuxdoc-sgml-mode-hook 'turn-on-font-lock)
  36. ;; 
  37. ;; Caveat: I've had problems getting sgml/html code to work with
  38. ;;         lazy-lock. Currently under investigation.
  39. ;;; Code:
  40.  
  41. (require 'sgml-mode)
  42.  
  43. (defvar  linuxdoc-sgml-tag-alist 
  44.   (let* ((htmlurl '(("ftp:") ("file:") ("finger:")
  45.             ("gopher:") ("http:") ("mailto:") ("news:")
  46.             ("rlogin:") ("telnet:") ("tn3270:") ("wais:")
  47.             ("/cgi-bin/")))
  48.      (name '(str))
  49.      (id '(str)))
  50.     `(("abstract" \n)
  51.       ("article" \n)
  52.       ("author" t)
  53.       ("bf")
  54.       ("date" t)
  55.       ("descrip" \n)
  56.       ("enum" \n)
  57.       ("footnote")
  58.       ("htmlurl" t ("url" ,@htmlurl) ("name" ,@name))
  59.       ("item" t)
  60.       ("itemize" \n)
  61.       ("label" ("id" ,@id))
  62.       ("p" t)
  63.       ("quote" \n)
  64.       ("ref" t ("id") ("name" ,@name))
  65.       ("sect"   (t  (setq str (read-input "Sect: ")) "\n<p>\n"))
  66.       ("sect1"  (t  (setq str (read-input "Sect1: ")) "\n<p>\n"))
  67.       ("sect2"  (t  (setq str (read-input "Sect2: ")) "\n<p>\n"))
  68.       ("sect3"  (t  (setq str (read-input "Sect3: ")) "\n<p>\n"))
  69.       ("sect4"  (t  (setq str (read-input "Sect4: ")) "\n<p>\n"))
  70.       ("tag //" t)
  71.       ("title" (t  (setq str (read-input "Title: ")) "\n"))
  72.       ("toc" t)
  73.       ("tscreen")
  74.       ("tt" (nil (setq str (read-input "Text: "))))
  75.       ("url" t ("url" ,@htmlurl) ("name" ,@name))
  76.       ("verb" \n)))
  77.     "Linuxdoc specific tags")
  78.  
  79. (defvar  linuxdoc-sgml-tag-help 
  80.   '(("abstract" . "Abstract of the document") 
  81.     ("article" . "Beginning of the article")
  82.     ("author" . "Name of the Author")
  83.     ("bf" . "Bold font")     
  84.     ("date" . "Date")
  85.     ("descrip" . "Description environment")
  86.     ("enum" . "Enumerated items")
  87.     ("footnote" . "Footnotes")
  88.     ("htmlurl" . "Insert a URL that shows up only in the HTML version")
  89.     ("item" . "An enumerated or unordered item")
  90.     ("itemize" . "Unordered list")
  91.     ("label" . "A label for cross reference")
  92.     ("p" . "Marks the end of the sect* tag")
  93.     ("quote" . "Quote a piece of text")
  94.     ("ref" . "Cross reference")
  95.     ("sect"  . "Main section heading") 
  96.     ("sect1" . "Level 1 section heading")
  97.     ("sect2" . "Level 2 section heading")
  98.     ("sect3" . "Level 3 section heading") 
  99.     ("sect4" . "Level 4 section heading")
  100.     ("tag //"   . "A description tag")    
  101.     ("title" . "Title of the document")
  102.     ("toc" . "The table of contents")
  103.     ("tscreen" . "Indents the text and uses tt font")
  104.     ("tt" . "Uses the tt font")     
  105.     ("url" . "Insert a URL")
  106.     ("verb" . "The text will be typed verbatim"))
  107.   "Help for linuxdoc specific tags")
  108.  
  109. (defvar linuxdoc-sgml-tag-face-alist
  110.   '(("abstract" . underline)
  111.     ("article" . italic)
  112.     ("author" . italic)
  113.     ("bf" . bold)
  114.     ("date" . italic)
  115.     ("descrip" . font-lock-reference-face)
  116.     ("enum" . font-lock-type-face)
  117.     ("footnote" . font-lock-keyword-face)
  118.     ("htmlurl" . font-lock-string-face)
  119.     ("item" . font-lock-function-name-face)
  120.     ("itemize" . font-lock-type-face)
  121.     ("label" . font-lock-comment-face)
  122.     ("p" . default)
  123.     ("quote" . underline)
  124.     ("ref" . font-lock-comment-face)
  125.     ("sect"  . underline)
  126.     ("sect1" . underline)
  127.     ("sect2" . underline)
  128.     ("sect3" . underline)
  129.     ("sect4" . underline)
  130.     ("tag"   . font-lock-function-name-face)
  131.     ("title" . underline)
  132.     ("toc" . default)
  133.     ("tscreen" . underline)
  134.     ("tt" . underline)
  135.     ("url" . font-lock-string-face)
  136.     ("verb" . underline))
  137.     "Value of `sgml-tag-face-alist' for linuxdoc-sgml mode.")
  138.  
  139. (defvar linuxdoc-sgml-font-lock-keywords
  140.     '(("<\\([^>]*\\)>" . font-lock-comment-face))
  141.     "Patterns to highlight in LD-SGML buffers.")
  142.  
  143. ;;;###autoload
  144. (defun linuxdoc-sgml-mode ()
  145.   "Major mode based on SGML mode for editing linuxdoc-sgml documents.
  146. See the documentation on sgml-mode for more info. This mode
  147. understands the linuxdoc-sgml tags."
  148.   (interactive)
  149.   (sgml-mode-common linuxdoc-sgml-tag-face-alist nil)
  150.   (use-local-map sgml-mode-map)
  151.   (make-local-variable 'sgml-tag-alist)
  152.   (make-local-variable 'sgml-face-tag-alist)
  153.   (make-local-variable 'sgml-tag-help)
  154.   (make-local-variable 'outline-regexp)
  155.   (make-local-variable 'outline-heading-end-regexp)
  156.   (make-local-variable 'outline-level)
  157.   (make-local-variable 'sgml-font-lock-keywords)
  158.   (setq mode-name "LD-SGML"
  159.         major-mode 'linuxdoc-sgml-mode
  160.     sgml-tag-alist linuxdoc-sgml-tag-alist
  161.     sgml-face-tag-alist linuxdoc-sgml-tag-face-alist
  162.     sgml-tag-help linuxdoc-sgml-tag-help
  163.     outline-regexp "^.*<sect[1-4]\\>"
  164.     outline-heading-end-regexp "<p>"
  165.     sgml-font-lock-keywords-1 (append sgml-font-lock-keywords-1
  166.                       linuxdoc-sgml-font-lock-keywords
  167.                       sgml-font-lock-keywords)
  168.                       
  169.     outline-level (lambda ()
  170.             (char-after (1- (match-end 0)))))
  171.   (run-hooks 'linuxdoc-sgml-mode-hook))
  172.  
  173.  
  174. (provide 'linuxdoc-sgml)
  175.  
  176. ;;; linuxdoc-sgml.el ends here
  177.